<?php require_once LAYOUTPATH.'layout_header.php'; ?>

<?php require_once FLASHPARTIAL; ?>

<div id="bricabox_header">
	<h1>Edit your account</h1>
</div>

<?php $user = $this->userland->current_user(); ?>

<form id="edit_account" action="/account/save_account" method="post" enctype="multipart/form-data">
	<fieldset>
		<div id="logged_in_with">
			You're logged in using
			<?php if ($user->identity_url): ?>
			your OpenID
			<img src="/assets/images/openid.gif" alt="OpenID" />&nbsp;<span><?php echo $user->identity_url; ?></span>
			<?php else: ?>
			your <img src="/assets/images/bricabox_id.png" alt="BricaBox ID" height="11px" />
			<span><?php echo $user->login; ?></span>
			<?php endif; ?>
		</div>
		
		<h2>Your profile URL</h2>
		<div>
			<label for="user_url_alias">Choose a profile URL:</label><br />
			<?php echo APP_ROOT_URL; ?>/person/<input onkeyup="checkURL();" type="text" id="user_url_alias" name="user[url_alias]" value="<?php echo user_url($user); ?>" /><br />
			<div id="user_url_check"></div>
		</div>
		
		<script type="text/javascript" charset="utf-8">
			function checkURL()
			{
				var el = $('#user_url_alias');
				var ck = $('#user_url_check');
				ck.load('/account/check_url_alias', {url_alias: el.val()});
			}
		</script>
		
		<h2>Basic info</h2>
		<div>
			<label for="user_email"><span class="req">*</span>Email address:</label><br />
			<input type="text" id="user_email" name="user[email]" value="<?php echo $user->email; ?>" />
		</div>
		
		<div>
			<label for="user_display_name">Your name (this is what is displayed on BricaBox):</label><br />
			<input type="text" id="user_display_name" name="user[display_name]" value="<?php echo username($user); ?>" />
		</div>
		
		<div>
			<label for="user_zip"><span class="req">*</span>Zip or Postal Code:</label><br />
			<input type="text" id="user_zip" name="user[zip]" value="<?php echo $user->zip; ?>" maxlength="12" />
		</div>
		
		<div>
			<label for="user_avatar">Upload your picture (if you already have one, it'll be replaced with the one you upload) Make sure it is at least 100x100 pixels and square:</label><br />
			<input type="file" id="user_avatar" name="user[avatar]" />
		</div>
		
		<div>
			<label for="user_bio">Tell us a little about yourself:</label><br />
			<textarea id="user_bio" name="user[bio]" rows="5" cols="45"><?php echo $user->bio; ?></textarea>
		</div>
		
		<h2>Notification Preferences</h2>
		<div>
			<input type="hidden" name="user[notify_comments]" value="0" />
			<input type="checkbox" id="notify_comments" name="user[notify_comments]" value="1"<?php if ($user->notify_comments) echo ' checked="checked"'; ?> />
			<label for="notify_comments">Email me when someone comments on my profile</label>
		</div>
		
		<div>
			<input type="hidden" name="user[notify_following]" value="0" />
			<input type="checkbox" id="notify_following" name="user[notify_following]" value="1"<?php if ($user->notify_following) echo ' checked="checked"'; ?> />
			<label for="notify_following">Email me when someone follows me</label>
		</div>
		
		<div>
			<input type="hidden" name="user[optinnewsletter]" value="0" />
			<input type="checkbox" id="optinnewsletter" name="user[optinnewsletter]" value="1"<?php if ($user->optinnewsletter) echo ' checked="checked"'; ?> />
			<label for="optinnewsletter">I'd like to occasionally receive the BricaBox Newsletter</label>
		</div>
		
		<?php if (!strlen($user->identity_url)): ?>
		<h2>Optional: Change your password</h2>
		<div>
			<label for="password">New password (only enter a password if you'd like to change your existing one):</label><br />
			<input type="password" id="password" name="password" value="" />
		</div>
		
		<div>
			<label for="password_conf">Confirm new password:</label><br />
			<input type="password" id="password_conf" name="password_conf" value="" />
		</div>
		<?php endif; ?>
		
		<div class="controls">
			<input type="submit" value="Save changes" />
			or <a href="/person/<?php echo $user->login; ?>">cancel</a>
		</div>
		
		<!--
		<h2>Cancel your BricaBox account</h2>
		<p>We'd hate to see you go, but if you want to cancel your account, use the link below.</p>
		<p style="margin-top: 8px;"><a style="color: #b00; border: none; font-weight: bold;" href="/account/cancel" onclick="return confirm('Are you absolutely sure? There is no undo. Once your account is cancelled it\'s gone forever.');">Cancel my account</a></p>-->
	</fieldset>
</form>

<?php require_once LAYOUTPATH.'layout_footer.php'; ?>